//
//  TSAuditTaskDetailController.m
//  chart
//
//  Created by 曾斌 on 16/4/9.
//  Copyright (c) 2016年 xu. All rights reserved.
//

#import "TSAuditTaskDetailController.h"

@implementation TSAuditTaskDetailController


-(UIActionSheet *)createActionSheet
{
    WS(weakSelf);
    if(weakSelf){
        return [[UIActionSheet alloc] initWithTitle:nil delegate:weakSelf cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"通过",@"不通过", nil];

    }else{
        return nil;
    }
}


#pragma mark - UIActionSheetDelegate
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0) {
        //通过
        [self pass];
        
    }else if (buttonIndex == 1) {
        //不通过
        [self dispass];
    }
}

-(void) pass
{
    WS(weakSelf);
    self.taskModel.requestParams =@{TSDictionaryKeyDefine_Id:self.taskId};
    [self.taskModel fetchWithPath:kRequestUrl_Task_Action_Audit_AGREE completionHandler:^(BOOL isSucceeded, NSError *error) {
        if (!weakSelf) {
            return;
        }
        [weakSelf.navigationController popToRootViewControllerAnimated:YES];
    } NoProgress:NO];
}

-(void) dispass
{
    WS(weakSelf);
    self.taskModel.requestParams =@{TSDictionaryKeyDefine_Id:self.taskId};
    [self.taskModel fetchWithPath:kRequestUrl_Task_Action_Audit_DISAGREE completionHandler:^(BOOL isSucceeded, NSError *error) {
        if (!weakSelf) {
            return;
        }
        [weakSelf.navigationController popToRootViewControllerAnimated:YES];
    } NoProgress:NO];
}


@end
